using System.Linq;
using System.Security.Principal;

namespace TaskKernel.Domain.Services.Action
{
    public sealed class CustomPrincipal : WindowsPrincipal
    {
        private readonly RoleEnum _role;

        public CustomPrincipal(WindowsIdentity identity, RoleEnum role)
            : base(identity)
        {
            _role = role;
        }

        public override bool IsInRole(string role)
        {
            var arrayRole = role.Split(',');
            return arrayRole.Any(item => _role.ToString().Equals(item.Trim()));
        }
    }
}